home *** CD-ROM | disk | FTP | other *** search
/ Delphi 2.0 - Programmer's Utilities Power Pack / Delphi 2.0 Programmer's Utilities Power Pack.iso / s_to_z / tpack / debugctl.pas < prev    next >
Encoding:
Pascal/Delphi Source File  |  1996-09-15  |  4.2 KB  |  145 lines

  1. unit Debugctl;
  2.  
  3. interface
  4.  
  5. uses
  6.   SysUtils, WinTypes, WinProcs, Messages, Classes, Graphics, Controls,
  7.   Forms, Dialogs, StdCtrls, Buttons, Toolbar, ExtCtrls
  8. , Debug
  9. , UserInfo;
  10.  
  11. type
  12.   TDebugControl= class(TDialogShell)
  13.   private
  14.     {uses vars global to this unit}
  15.   protected
  16.     function GetState:TDebugExtendedComponentState;
  17.     procedure SetState(Value:TDebugExtendedComponentState);
  18.     function GetFlags:TDebugExtendedComponentFlags;
  19.     procedure SetFlags(Value:TDebugExtendedComponentFlags);
  20.     function GetTest:Boolean; override;
  21.     procedure SetTest(Value:Boolean); override;
  22.     function GetEnabled:Boolean;
  23.     procedure SetEnabled(Value:Boolean);
  24.   public
  25.     constructor Create(aOwner:TComponent); Override;
  26.     procedure Notification(AComponent: TComponent; Operation: TOperation); override;
  27.     destructor Destroy; Override;
  28.     procedure Loaded; Override;
  29.   published
  30.     property Options: TDebugExtendedComponentFlags read GetFlags write SetFlags;
  31.     property Enabled: Boolean read GetEnabled write SetEnabled stored false;
  32.     property State: TDebugExtendedComponentState read GetState write SetState stored false;
  33.     end;
  34.  
  35. implementation
  36.  
  37. {-----------------------------------------------------------------------------------------}
  38. { TDebugControl                                                                            }
  39. {-----------------------------------------------------------------------------------------}
  40.  
  41. constructor TDebugControl.Create(aOwner:TComponent);
  42. begin
  43.   inherited Create(aOwner);
  44.   DebugState:=DebugState-[decDestroying];
  45.   Options:= DebugFlags;
  46.   if (decCreate in DebugFlags) then
  47.     DebugLog(nil,'Create '+ClassName);
  48. end;
  49.  
  50. destructor TDebugControl.Destroy;
  51. begin
  52.   if (decDestroy in DebugFlags) then
  53.     DebugLog(nil,'Destroy '+ClassName);
  54.   DebugState:=DebugState+[decDestroying]-[decActive];
  55.   Options:=[];
  56.   {DebugDlg.Free;
  57.   DebugDlg:=nil;}
  58.   inherited Destroy;
  59. end;
  60.  
  61. procedure TDebugControl.Loaded;
  62. begin
  63.   if (decLoaded in DebugFlags) then
  64.     DebugLog(nil,'Loaded '+ClassName);
  65.   inherited Loaded;
  66.   ComponentIndex:=0;        {makes itself first component.}
  67. end;
  68.  
  69. procedure TDebugControl.Notification(AComponent: TComponent; Operation: TOperation);
  70. begin
  71.   inherited Notification(AComponent, Operation);
  72.   if aComponent<>nil then begin
  73.     if (aComponent is TDebugControl) and (Operation = opRemove) then
  74.       DebugState:=DebugState-[decDestroying]+[decActive];
  75.     if (([decInsert, decRemove]*DebugFlags)<>[]) then
  76.       if (Operation = opRemove) and (decRemove in DebugFlags) then
  77.         DebugLog(nil,'Remove '+AComponent.Name+'('+AComponent.ClassName+')')
  78.       else
  79.         if (Operation = opInsert) and (decInsert in DebugFlags) then
  80.           DebugLog(nil,'Insert '+AComponent.Name+'('+AComponent.ClassName+')');
  81.     end;
  82. end;
  83.  
  84. {}
  85.  
  86. function TDebugControl.GetState:TDebugExtendedComponentState;
  87. begin
  88.   Result:=DebugState;
  89. end;
  90.  
  91. procedure TDebugControl.SetState(Value:TDebugExtendedComponentState);
  92. begin {DebugState:=Value;} {read only}
  93. end;
  94.  
  95. {}
  96.  
  97. function TDebugControl.GetEnabled:Boolean;
  98. begin
  99.   Result:=decEnabled in DebugFlags;
  100. end;
  101.  
  102. procedure TDebugControl.SetEnabled(Value:Boolean);
  103. begin
  104.   if Value and (not GetEnabled) then
  105.     AdjustDebugFlags(DebugFlags+[decEnabled])
  106.   else
  107.     if (not Value) and GetEnabled then
  108.       AdjustDebugFlags(DebugFlags-[decEnabled]);
  109. end;
  110.  
  111. {}
  112.  
  113. function TDebugControl.GetFlags:TDebugExtendedComponentFlags;
  114. begin
  115.   Result:=DebugFlags;
  116. end;
  117.  
  118. procedure TDebugControl.SetFlags(Value:TDebugExtendedComponentFlags);
  119. begin
  120.   if (csLoading in ComponentState) then
  121.     DebugFlags:=Value
  122.   else
  123.     Debug.AdjustDebugFlags(Value); {adjusts state and changes flags}
  124. end;
  125.  
  126. {}
  127.  
  128. {-----------------------------------------------------------------------------------------}
  129. { DESIGN TIME TEST PROCS                                                                  }
  130. {-----------------------------------------------------------------------------------------}
  131.  
  132. procedure TDebugControl.SetTest(Value:Boolean);
  133. begin
  134.   DebugLog(nil,'Test '+ClassName);
  135. end;
  136.  
  137. function TDebugControl.GetTest:Boolean;
  138. begin
  139.   Result:= decActive in DebugState;
  140. end;
  141.  
  142. end.
  143.  
  144.  
  145.